//Magnus Baunsgaard Kristensen s140168
//Jonathan Yannick Thomassen s125070

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

public class KnapPanel2 extends JPanel {

  JButton buttonE = new JButton();
  JButton buttonF = new JButton();
  JButton buttonG = new JButton();
  JButton buttonH = new JButton();

  Konsol ejer;

  public KnapPanel2(Konsol k) {
    try {
      init();
    } catch (Exception e) {
    }
    ejer = k;
  }

  private void init() throws Exception {
    buttonE.setText("E");
    buttonF.setText("F");
    buttonG.setText("G");
    buttonH.setText("H");

    buttonE.setBounds(10, 10, 80, 50);
    buttonF.setBounds(10, 75, 80, 50);
    buttonG.setBounds(10, 140, 80, 50);
    buttonH.setBounds(10, 205, 80, 50);

    this.setLayout(null);
    this.add(buttonE);
    this.add(buttonF);
    this.add(buttonG);
    this.add(buttonH);

    buttonE.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonE_actionPerformed(e);
      }
    });

    buttonF.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonF_actionPerformed(e);
      }
    });

    buttonG.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonG_actionPerformed(e);
      }
    });

    buttonH.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonH_actionPerformed(e);
      }
    });
  }

  void buttonE_actionPerformed(ActionEvent e) {
    ejer.knapInput("E");
  }

  void buttonF_actionPerformed(ActionEvent e) {
    ejer.knapInput("F");
  }

  void buttonG_actionPerformed(ActionEvent e) {
    ejer.knapInput("G");
  }

  void buttonH_actionPerformed(ActionEvent e) {
    ejer.knapInput("H");
  }
}
